package bb.lanxing.util.ui;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;

public class LinearItemDecoration extends RecyclerView.ItemDecoration {
    private int mDividerHeight;
    private Paint mLinePaint;

    public LinearItemDecoration(int i, int i2) {
        Paint paint = new Paint();
        this.mLinePaint = paint;
        paint.setColor(i);
        this.mDividerHeight = i2;
    }

    @Override
    public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
        int i = this.mDividerHeight;
        for (int i2 = 0; i2 < recyclerView.getChildCount(); i2++) {
            View childAt = recyclerView.getChildAt(i2);
            int paddingLeft = recyclerView.getPaddingLeft();
            int width = recyclerView.getWidth() - recyclerView.getPaddingRight();
            int bottom = childAt.getBottom();
            canvas.drawRect(paddingLeft, bottom, width, bottom + i, this.mLinePaint);
        }
    }

    @Override
    public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) {
        super.getItemOffsets(rect, view, recyclerView, state);
        rect.bottom = this.mDividerHeight;
    }
}
